package com.aboo.pub.exception;

import org.apache.log4j.Logger;

/**
 * @author Yata Aboo
 * @Date 2012-9-17
 * @Desc 基础类异常
 */
public class BasicException extends Exception {

	private static final long serialVersionUID = -8251490287295692898L;
	private static final Logger logger = Logger.getLogger(BasicException.class);
	
	private ErrorMessage errorMessage;
	
	public BasicException(ErrorMessage errorMessage) {
		this.errorMessage = errorMessage;
		logger.error("ErrorCode: " + errorMessage.getErrorCode());
	}
	
	public BasicException(ErrorMessage errorMessage, Throwable cause) {
		this.errorMessage = errorMessage;
		logger.error("ErrorCode: " + errorMessage.getErrorCode(), cause);
	}

	public BasicException(String msg) {
		super(msg);
		logger.error("Message: " + msg);
	}
	
	public BasicException(String msg, Throwable cause) {
		super(msg, cause);
		logger.error("Message: " + msg, cause);
	}

	public ErrorMessage getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(ErrorMessage errorMessage) {
		this.errorMessage = errorMessage;
	}
	
}
